package com.ccsu.eb.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ccsu.eb.service.EbCommentService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

/**
 * @Description: 用一句话描述
 * @Auther: 新梦想*陈超
 * @Date: 2022/3/18 14:05
 */
@Controller
@RequestMapping("comment")
public class EbCommentController {

    @Resource
    private EbCommentService ebCommentService;
    /**
     * 分页展示留言信息，需要按时间降序
     * @param model
     * @param pnum
     * @return
     */
    @RequestMapping("list")
    public String list(Model model,
                       @RequestParam(value = "pnum",defaultValue = "1")Integer pnum){
        //TODO 1.调用service查询按留言列表
        Page commentPage = ebCommentService.list(pnum);
        //TODO 2.绑定到model---数据
        model.addAttribute("commentPage",commentPage);
        //TODO 3.返回view--html
        return "guestbook";///templates/guestbook.html
    }
}
